home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / lzw4c13.zip / SEE_ARC.C < prev    next >
Text File  |  1993-08-29  |  2KB  |  95 lines

  1. /*
  2. **   SEE_ARC.C       Copyright (C) 1992 by MarshallSoft Computing, Inc.
  3. **
  4. **   This program is used to list files compressed with MK_ARC. For
  5. **   example, to list all the files in 'C.ARF', type:
  6. **
  7. **      SEE_ARC C.ARF
  8. */
  9.  
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <dos.h>
  13. #include <fcntl.h>
  14. #include <sys\types.h>
  15. #include <sys\stat.h>
  16. #include <io.h>
  17.  
  18. #include "LZW4C.H"
  19. #include "RW_IO.H"
  20. #include "DIR_IO.H"
  21.  
  22. void SayError(int);
  23.  
  24. void main(argc,argv)
  25. int argc;
  26. char *argv[];
  27. {int i, k, c;
  28.  int RetCode;
  29.  char Filename[15];
  30.  int Files = 0;
  31.  int Dummy();
  32.  /* begin */
  33.  if(argc!=2)
  34.    {printf("Usage: SEE_ARC <archive_filespec>\n");
  35.     exit(1);
  36.    }
  37.  RetCode = InitLZW(malloc,14);
  38.  if(RetCode<0)
  39.    {SayError(RetCode);
  40.     exit(2);
  41.    }
  42.  puts("\nSEE_ARC 1.0: Type any key to abort...");
  43.  /* open input file for expansion */
  44.  if(!ReaderOpen(argv[1])) exit(4);
  45.  for(i=0;;i++)
  46.    {if(kbhit())
  47.       {puts("\n...Aborted by user !");
  48.        break;
  49.       }
  50.     /* get filename */
  51.     for(k=0;k<5;k++)
  52.        {c = Reader();
  53.         if(c==-1)
  54.            {ReaderClose();
  55.             TermLZW(free);
  56.             printf("\n%d files\n",Files);
  57.             exit(0);
  58.            }
  59.         /* skip past any 0's */
  60.         if(c!='\0') break;
  61.        }
  62.     Filename[0] = (char)c;
  63.     for(k=1;k<13;k++)
  64.        {c = Reader();
  65.         Filename[k] = (char)c;
  66.         if(c=='\0') break;
  67.        }
  68.     if(c!='\0')
  69.        {printf("ERROR: Cannot find filename in %s\n",argv[1]);
  70.         TermLZW(free);
  71.         exit(0);
  72.        }
  73.     if(strcmp(Filename,argv[1])==0)
  74.       {printf("ERROR: Archive contains file '%s' named same as archive\n",argv[1]);
  75.        exit(1);
  76.       }
  77.     else
  78.       {/* open output file */
  79.        Files++;
  80.        printf("%3d: %s \n",Files,Filename);
  81.        /* do the expansion */
  82.        if((RetCode=Expand(Reader,Dummy))<0)
  83.          {SayError(RetCode);
  84.           exit(5);
  85.          }
  86.       }
  87.    }
  88. } /* end main */
  89.  
  90. int Dummy(TheByte)
  91. char TheByte;
  92. {
  93.  /* into the bit bucket ! */
  94.  return(0);
  95. }